package com.example.mountainwalker.mapper;

import com.example.mountainwalker.entity.GroupTourFavoriteInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;
@Mapper
public interface GroupTourFavoriteMapper {
    @Select("select * from GroupTourFavorite")
    List<GroupTourFavoriteInfo>getGroupTourFavorite();

    @Select("select * from GroupTourFavorite where GroupTourFavoriteID= #{id}")
    GroupTourFavoriteInfo getGroupTourFavoriteById(Integer id);


    @Delete("delete from GroupTourFavorite where GroupTourFavoriteID= #{id}")
    int deleteGroupTourFavoriteById(Integer id);

    @Insert("INSERT INTO GroupTourFavorite(UserID, GroupTourID, FavoriteTime) " +
            "VALUES(#{userID}, #{groupTourID}, #{favoriteTime})")
    int addGroupTourFavorite(GroupTourFavoriteInfo groupTourFavoriteInfo);

    @Update("UPDATE GroupTourFavorite SET UserID=#{userID}, GroupTourID=#{groupTourID}, " +
            "FavoriteTime=#{favoriteTime} WHERE GroupTourFavoriteID=#{groupTourFavoriteID}")
    int updateGroupTourFavorite(GroupTourFavoriteInfo groupTourFavoriteInfo);
}
